package com.example.rightmost.controller.user;

import com.example.rightmost.entity.Pyq;
import com.example.rightmost.entity.Result;
import com.example.rightmost.entity.User;
import com.example.rightmost.service.PyqService;
import com.example.rightmost.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:javayhch
 * @date:2024/8/20
 * @description:
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    public UserService userService;
    @Autowired
    public PyqService pyqService;

    @RequestMapping("/reg")
    public Result reg(@RequestBody User user){
        return userService.reg(user);
    }

    @RequestMapping("/login")
    public Result login(@RequestBody User user){
        return userService.login(user);
    }

    @RequestMapping("/getInfoById")
    public Result getInfoById(@RequestParam int id){
        return userService.getInfoById(id);
    }

    @RequestMapping("/pyq")
    public List<Pyq> pyq() {
        List<Pyq> pyqs = pyqService.list();
        return pyqs;
    }

    @RequestMapping("/followPyq")
    public List<Pyq> followPyq(@RequestParam int userId) {
        List<Pyq> followList = pyqService.followList(userId);
        return followList;
    }
}
